Re: [SQL] Cursors
От | lynch@lscorp.com (Richard Lynch) |
---|---|
Тема | Re: [SQL] Cursors |
Дата | |
Msg-id | v02140b6cb22eb61f601e@[207.152.64.133] обсуждение исходный текст |
Список | pgsql-sql |
>I am new to Postgre (and databases), and just figuring how to >use it. I see numerous references to cursors, but I do not >understand what they are for. Could someone point me to someplace >to read, or give me one paragraph to enlighten me. Suppose you have a *HUGE* database. Like Publisher's Clearinghouse you may already have won a million dollars huge. If you were going to look at it on the web, you really, REALLY, *REALLY* don't want to do a query like: "select * from losers order by lastname, firstname" It's pretty much guaranteed to choke the machine, eh? "Imminent Death of the Internet, Film at 11." So, you use a cursor. A cursor allows you to select a specific range within a large set of records, but also have order by and group by behave properly. By creating a cursor and using that cursor in a query, the result set can be calculated by the backend, but only a tiny fraction of that set will be transmitted to the the browser at one time. The backend *MIGHT* even be really smart and not have to do the *WHOLE* sort, before allowing you to get the first N records, but I dunno about that for sure. The details on how to use cursors in PostgreSQL are in the archives, so I won't repeat them here. Disclaimer: Main because I dunno how to use them. I've never had a db that large. :-) -- -- -- "TANSTAAFL" Rich lynch@lscorp.com
В списке pgsql-sql по дате отправления: